package cn.bjxy.shishaolong.system.config;

import cn.bjxy.shishaolong.system.interceptor.AuthorizationInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器配置  将自定义拦截器注入到系统中
 *
 * @Author 时少龙
 * @Date 2019-04-16 17:37
 * @Version 1.0
 */
@Component
public class InterceptorConfig implements WebMvcConfigurer {
    @Autowired
    private AuthorizationInterceptor authorizationInterceptor;  // 自定拦截器必须让spring注入，否则在在拦截器中不能使用spring注入
    // 配置拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authorizationInterceptor).addPathPatterns("/api/**");  // 只拦api
    }
}
